<?php

$vars = $_SESSION['site_config_post'];

$sql = $_SESSION['sql_post'];

$string = '<?php

	if(!defined(\'YMT\')) exit;

	// locale information is now set by default in MainFramework.class.php
	//setlocale(LC_ALL, SiteConfig::DefaultLanguage);
	
	/**
	 * build at '. date("d.m.Y - H:i") . ' with avance installer version '.$_installer.'
	 */
	Class SiteConfig
	{
		
		// Global Site Settings
		
		const AdminMail = \''.$vars['AdminMail'].'\';
		
		const Domain = \''.$vars['Domain'].'\'; // do not forget the trailing slash!
		
		const ActiveTheme = \''.$vars['ActiveTheme'].'\';
	
		const DefaultLanguage = \'de_CH\';
		
		const LangFiles = \'backend\'; // seperate more items with ";" (backend;basket;eshop;globals)
		
		const DefaultCat = 1; // Default case: SELECT * FROM cms_cat WHERE id=SiteConfig::DefaultCat
		
		const ImageResizeSmall = 100;

		const ImageResizePortrait = 200;
		
		const ImageResizeFull = 600;
		
		const RewriteLinks = '.$vars['RewriteLinks'].';
		
		const RewriteLinksDisplayLang = false;
		
		const RewriteLinksDisplayCat = false;
		
		// Mailer Settings
		
		const MailSenderName = \''.$vars['MailSenderName'].'\';
		
		const MailSenderMail = \''.$vars['MailSenderMail'].'\';
		
		const MailSmtpHost = \''.$vars['MailSmtpHost'].'\';
		
		const MailPort = '.$vars['MailPort'].';
		
		const MailSmtpUser = \''.$vars['MailSmtpUser'].'\';
		
		const MailSmtpPass = \''.$vars['MailSmtpPass'].'\'; // you can request this password on avancecms.ch if yours not working!
		
		// Database Informations
		
		const SqlHost = \''.$sql['sql_host'].'\';
		
		const SqlUser = \''.$sql['sql_user'].'\';
		
		const SqlPass = \''.$sql['sql_pass'].'\';
		
		const SqlDatabase = \''.$sql['sql_db'].'\';
		
		// Framework Design Settings (content parser informations for styles, titles or images)
		
		const ContentImageLeft = \'<a href="{name}full{mime}"><img src="{name}portrait{mime}" border="0" alt="{title}" title="{title}" align="left" /></a>\';
		
		const ContentImageMiddle = \'<center><a href="{name}full{mime}"><img src="{name}portrait{mime}" border="0" alt="{title}" title="{title}" /></a></center>\';
		
		const ContentImageRight = \'<a href="{name}full{mime}"><img src="{name}portrait{mime}" border="0" alt="{title}" title="{title}" align="right" /></a>\';

		const HighlightWrapper = \'<span style="background-color:yellow;">{value}</span>\';
		
		// System Check Options
		
		const forceSystemCheck = false; // should be turned to false after the website is in production!
		
		const SendErrors = '.$vars['SendErrors'].'; // will send all errors to the avance system developer team. it helps us to make the product better!
		
		const Debugger = true; // set the error_reporting(0) and does not allow debugger=true anymore
	}'; 

	$fp = fopen("../site_config.php", "w");
	
	$write = fwrite($fp, $string); 

	if($write)
	{
		echo '<p class="green">Ihre Konfigurations Datei wurde erfolgreich geschriebe.</p>';
		echo '<p class="info">Sie k&ouml;nnen jederzeit manuelle eintr&auml;ge vornehmen in der Datei site_config.php</p>';
		echo '<input type="button" onclick="location.href=\''.$vars['Domain'].'\'" value="Webseite Anzeigen" />';
		$_SESSION = array();
		unset($_SESSION);
	} else {
		echo '<p class="red">Es ist ein FEHLER passiert! Sie m&uuml;ssen die Konfigurations Datei (site_config.php) Manuel anpassen.';
	}
	
	fclose($fp); 
?>